﻿@using Nop.Core.Domain.Catalog
@{
    var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
    var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;

    //page title
    ViewBag.Title = T("Admin.Catalog.LowStockReport").Text;
}
@using (Html.BeginForm())
{
    <div class="section-header">
        <div class="title">
            <img src="@Url.Content("~/Administration/Content/images/ico-catalog.png")" alt="" />
            @T("Admin.Catalog.LowStockReport")
        </div>
        <div class="options">
        </div>
    </div>

    <table class="adminContent">
        <tr>
            <td>
                <div id="products-grid"></div>

                <script>
                    $(document).ready(function() {
                        $("#products-grid").kendoGrid({
                            dataSource: {
                                type: "json",
                                transport: {
                                    read: {
                                        url: "@Html.Raw(Url.Action("LowStockReportList", "Product"))",
                                        type: "POST",
                                        dataType: "json"
                                    }
                                },
                                schema: {
                                    data: "Data",
                                    total: "Total",
                                    errors: "Errors"
                                },
                                error: function(e) {
                                    display_kendoui_grid_error(e);
                                    // Cancel the changes
                                    this.cancelChanges();
                                },
                                pageSize: @(defaultGridPageSize),
                                serverPaging: true,
                                serverFiltering: true,
                                serverSorting: true
                            },
                            pageable: {
                                refresh: true,
                                pageSizes: [@(gridPageSizes)]
                            },
                            editable: {
                                confirmation: false,
                                mode: "inline"
                            },
                            scrollable: false,
                            columns: [
                                {
                                    field: "Name",
                                    title: "@T("Admin.Catalog.Products.Fields.Name")",
                                    width: 300,
                                    //if not a grouped product, then display
                                    template: "#:Name# # if(Attributes !== null) {# <br /><i> #=Attributes# </i> #} #"
                                }, {
                                    field: "ManageInventoryMethod",
                                    title: "@T("Admin.Catalog.Products.Fields.ManageInventoryMethod")",
                                    width: 150
                                }, {
                                    field: "StockQuantity",
                                    title: "@T("Admin.Catalog.Products.Fields.StockQuantity")",
                                    width: 100
                                }, {
                                    field: "Published",
                                    title: "@T("Admin.Catalog.Products.Fields.Published")",
                                    width: 100,
                                    headerAttributes: { style: "text-align:center" },
                                    attributes: { style: "text-align:center" },
                                    template: '<img src="@Url.Content("~/Administration/Content/images/")active-#=Published#.gif" />'
                                }, {
                                    field: "Id",
                                    title: "@T("Admin.Common.Edit")",
                                    width: 100,
                                    template: '<a href="Edit/#=Id#">@T("Admin.Common.Edit")</a>'
                                }
                            ]
                        });
                    });
                </script>
            </td>
        </tr>
    </table>
}